﻿using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Albatross.SharePoint.Explorer.ViewModels {
	public class ViewViewModel : ClientObjectViewModel {
		public ViewViewModel(ClientContext context, string name, View clientObject)
			: base(context, name, clientObject) {
		}
		public View View { get { return (View)ClientObject; } }
		public override string GetTreeItemTitle() {
			if (Name == string.Empty) {
				if (string.IsNullOrEmpty(View.Title)) {
					return View.ServerRelativeUrl;
				} else {
					return View.Title;
				}
			} else {
				return Name;
			}
		}
		public override string GetContentTitle() {
			if (string.IsNullOrEmpty(View.Title)) {
				return View.ServerRelativeUrl;
			} else {
				return string.Format("{0} ({1})", View.Title, View.ServerRelativeUrl);
			}
		}
	}
}
